/**
 * Get width and height of device
 * @return javascript object
 * @author OanhNN
 */
function viewport(){
    var e = window;
    var a = 'inner';
    if(!('innerWidth' in window)){
        a = 'client';
        e = document.documentElement || document.body;
    }
    return {
        width : e[a+'Width'] , 
        height : e[a+'Height']
    }
}
/**
 * Open popup windows
 * @return boolean false
 * @author OanhNN
 */
function openPopup(popupUrl,popupTitle,w,h){
    var popup_option = 'location=0,resizable=0,menubar=0,scrollbars=0,status=1,titlebar=0,toolbar=0';
    if(typeof(w) == 'undefined'){
        w = 300;
    }
    if(typeof(h) == 'undefined'){
        h = 300;
    }
    var l = (screen.width - w)/2;
    var t = (screen.height - h)/2;
    popup_option += ',width='+w+',height='+h+',top='+t+',left='+l;
    var popup = window.open(popupUrl,popupTitle,popup_option);
    popup.focus();
    return false;
}

/**
 * Close popup windows
 * @return  void
 * @author  OanhNN
 */
function closePopup(callback){
    window.close();
    window.opener.focus();
    if(typeof(callback) == 'function'){
        window.opener.callback();
    } 
}